<template>
    <div class='input-select-list-custom'>
        <my-input :id="id"  disableds="true"  class='myInputs' :data="data" :isRequired="isRequired"  :appid="appid"></my-input>
        <!--my-input :attribute="inputAttribute" class='myInputs' :data="data" :appid="appid"></my-input-->
        <el-button type="primary" class="butttonSelect" @click="openWin" v-if="isreadonly!='Y'">选择</el-button>


       <el-dialog
            title="选择"
            :visible.sync="dialogVisible"
            width="90%"
            append-to-body>
            <div style="height:70VH" v-if="extype=='cemeterySelect'&&dialogVisible">
                <cemetery-select ref="items" :data="data" :exkey="exkey" :pId="pId"></cemetery-select>
                <!--router-view name="exRouter"></router-view-->
            </div>
             <div style="height:70VH" v-if="extype=='cemeterySelect2'&&dialogVisible">
                <cemetery-select ref="items" :data="data" :exkey="exkey" :pId="pId" gm="Y"></cemetery-select>
                <!--router-view name="exRouter"></router-view-->
            </div>
            <div style="height:70VH" v-if="extype=='cemeterySelect3'&&dialogVisible">
                <cemetery-select ref="items" :data="data" :exkey="exkey" :pId="pId" gm="A"></cemetery-select>
                <!--router-view name="exRouter"></router-view-->
            </div>
             <div style="height:70VH" v-if="extype=='storage'&&dialogVisible">
                <storager ref="items" :data="data" :exkey="exkey" :pId="pId" isSelect="Y"></storager>
                <!--router-view name="exRouter"></router-view-->
            </div>
            <span slot="footer" class="dialog-footer">
                <el-button @click="dialogVisible = false">取 消</el-button>
                <el-button type="primary" @click="selects">选 择</el-button>
            </span>
        </el-dialog>                 
    </div>
    
</template>
<script>
import myInput  from './myInput.vue'
import CemeterySelect  from '../../views/gm/CemeterySelect.vue'
import storager  from '../../views/byg/storager.vue'
export default {
    name:"input-select-list-custom",
    props:['exkey','extype','id','label','data','appid','dataField','isRequired'],
    components: {
        myInput,
        CemeterySelect,
        storager
    },

    data(){
        return{
            dialogVisible:false,
            pId:"",
            isreadonly:"N"
            /*inputAttribute:{
                id:this.id,
                disableds:"true",
                isReadOnly:"Y",
                isRequired:this.required
            }*/
        }
    },
     provide: function () {
        return {
            selectClickOK: this.selects
        }
    },
    created(){
        let ids=this.id.split(".");
        this.pId=ids[0];
        try{
            if(this.exkey.readonlys){
                for(let i=0;i<this.exkey.readonlys.length;i++){
                    let id=this.exkey.readonlys[i].id;
                    let opr=this.exkey.readonlys[i].opr;
                    let vals=this.exkey.readonlys[i].val;
                    let val_=this.data[this.pId][id];
                    if(opr=="等于"&&vals==val_){
                        this.isreadonly="Y";
                    }
                    if(opr=="不等于"&&vals!=val_){
                        this.isreadonly="Y";
                    }

                }
            }
        }catch(e){}
    },
    methods:{
        openWin(){
            //this.$router.push({path:this.exkey});
            this.dialogVisible=true;
        },
        selects(){
            console.log(this.$refs.items,"items======================");
            if(this.$refs.items.selectOk())
                this.dialogVisible=false;
        }
    }
}
</script>
<style scoped>
    .input-select-list-custom{
        display:flex;
        flex-direction: row;
    }
    .butttonSelect{
        width:50px;
        margin-left:5px;
    }
    .myInputs{
        flex:1;
    }
</style>